list-[id].html.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <ShopPageHead></ShopPageHead>
  3. <main class="index_main" id="all_vue">
  4. <HomeAdvertising :imgurl="adImg1"></HomeAdvertising>
  5. <ShopSubMenu2></ShopSubMenu2>
  6. <div class="breadcrumb_box pc_none">
  7. <span class=" ">当前位置:</span>
  8. <NuxtLink
  9. :to="`/xiangcunshangcheng/index.html`"
  10. class=" "
  11. >
  12. 乡村商城
  13. </NuxtLink>
  14. <span class=" ">&gt;</span>
  15. <NuxtLink
  16. :to="`/xiangcunshangcheng/search/search`"
  17. >
  18. 搜索
  19. </NuxtLink>
  20. <span class=" ">&gt;</span>
  21. <span class=" "> 求购</span>
  22. </div>
  23. <div class="categ_crumb_box clearfix_2">
  24. <div class="categ_crumb_left phone_none">
  25. <span class="categ_crumb_left_a" title=""> 当前位置: </span>
  26. <NuxtLink
  27. :to="`/xiangcunshangcheng/index.html`"
  28. class="categ_crumb_left_a"
  29. >
  30. 乡村商城
  31. </NuxtLink>
  32. &gt;
  33. <NuxtLink
  34. :to="`/xiangcunshangcheng/search/search`"
  35. class="categ_crumb_left_a"
  36. >
  37. 搜索
  38. </NuxtLink>
  39. &gt;
  40. <span class="categ_crumb_left_text">求购</span>
  41. </div>
  42. </div>
  43. <!-- 供应信息列表 -->
  44. <div class=" clearfix">
  45. <div class="categ_1_index clearfix">
  46. <div class="categ_head_box clearfix_2">
  47. <a class="categ_head_a" href="" title="">供应信息列表</a>
  48. <div class="search_head_text_box phone_none">
  49. 搜索到有关的供应信息:共 
  50. <span class="search_head_text_red">{{total}}</span>
  51. </div>
  52. <div class="search_head_text_box pc_none">
  53. 搜索到共<span class="search_head_text_red">{{total}}</span>条
  54. </div>
  55. </div>
  56. <div class="categ_table clearfix">
  57. <div class="categ_table_head_box">
  58. <div class="categ_table_td_1">产品图片</div>
  59. <div class="categ_table_td_2">供求信息/公司</div>
  60. <div class="categ_table_td_3">发布时间</div>
  61. <div class="categ_table_td_4">地区</div>
  62. </div>
  63. <div class="categ_table_li" v-for="item in pageDataType2">
  64. <NuxtLink
  65. :to="getShopPathDetail1(item)"
  66. class="categ_table_li_a"
  67. :title="item.name"
  68. >
  69. <div class="categ_table_td_1">
  70. <img class="categ_table_td_1_img" :src="item.imgurl" :alt="item.name">
  71. </div>
  72. <div class="search_table_td_2 ">
  73. <div class="search_table_td_2_in clearfix">
  74. <div class="search_table_td_2_head dot1">
  75. {{ item.name }}
  76. </div>
  77. <div class="search_table_td_2_dot2 dot2">
  78. {{ item.description }}
  79. </div>
  80. </div>
  81. </div>
  82. <div class="categ_table_td_3">{{ getTime(item.created_at, 'year', 1) }}</div>
  83. <div class="categ_table_td_4 dot1">{{ item.city_name }}</div>
  84. </NuxtLink>
  85. </div>
  86. </div>
  87. </div>
  88. <!-- 分页器 -->
  89. <div class="pagination page_phone_none" v-if="total">
  90. <el-pagination
  91. size="small"
  92. background layout="prev, pager, next"
  93. :total="total"
  94. v-model:page-size="pageSize"
  95. prev-text="上一页"
  96. next-text="下一页"
  97. :current-page="pageNum"
  98. @current-change="changePage"
  99. />
  100. </div>
  101. <div class="pagination page_pc_none" v-if="total">
  102. <el-pagination
  103. pager-count="5"
  104. size="small"
  105. background
  106. layout=" pager "
  107. :total="total"
  108. class="mt-4"
  109. v-model:page-size="pageSize"
  110. :current-page="pageNum"
  111. @current-change="changePage" />
  112. </div>
  113. </div>
  114. <ShopHotNews></ShopHotNews>
  115. </main>
  116. <!-- 页面底部 -->
  117. <HomeFoot></HomeFoot>
  118. </template>
  119. <script setup>
  120. //1.页面必备方法 start ---------------------------------------->
  121. import { ref, onMounted,watch } from 'vue'
  122. import { ElMessage,ElPagination } from 'element-plus'
  123. //分页
  124. let pageNum = ref(1);
  125. let pageSize = ref(10);
  126. let total = ref(0);
  127. let changePage = (value) => {
  128. console.log("当前页码", value);
  129. navigateTo(`/xiangcunshangcheng/search/gongying/list-${value}.html`)
  130. }
  131. //1.页面必备方法 end ---------------------------------------->
  132. //2.页面路径 start ---------------------------------------->
  133. //2.1 获得页面数据id
  134. const route = useRoute();
  135. const router = useRouter()
  136. //2.4 获得cityid
  137. const cityId = ref(route.query.cityid)
  138. //2.5 获得keyword
  139. const keyword = ref(route.query.keyword)
  140. //2.页面路径 end ---------------------------------------->
  141. //4.搜索 start ---------------------------------------->
  142. //4.2 页面展示的数据
  143. //const pageDataType1 = ref([]);//供应数据
  144. const pageDataType2 = ref([]);//求购数据 此页面不需要求购数据
  145. //4.3 发起搜索
  146. const pageSearch = async () => {
  147. let params = {
  148. catid:346,//栏目id
  149. city_id:"",//城市id
  150. keyword:keyword,//搜索关键词
  151. page:1,
  152. pageSize:10,
  153. type_id:2
  154. }
  155. if(keyword.value == undefined || keyword.value == '' || keyword.value == 'NaN'){
  156. //删除变量params中的city_id参数
  157. delete params.keyword
  158. }else{
  159. params.keyword = keyword.value
  160. }
  161. if(cityId.value == undefined || cityId.value == '' || cityId.value == 'NaN'){
  162. //删除变量params中的city_id参数
  163. delete params.city_id
  164. }else{
  165. params.city_id = parseFloat(cityId.value)
  166. }
  167. const pageData = await requestDataPromise('/web/getWebsiteshopList', {
  168. method: 'GET',
  169. query: params,
  170. });
  171. if (pageData.code == 200) {
  172. pageDataType2.value = pageData.data.type2;
  173. total.value = pageData.data.type2_count;
  174. } else {
  175. console.log("错误位置:获得该页面数据失败!")
  176. }
  177. //开始请求数据
  178. console.log(params)
  179. console.log(pageData)
  180. }
  181. //页面初始化的时候调用一下搜索
  182. pageSearch();
  183. //4.4 每次路由一变化就重新请求数据
  184. //4.4.1 监听cityid
  185. watch(() => route.query.cityid, (newVal, oldVal) => {
  186. if(newVal != undefined){
  187. cityId.value = parseFloat(newVal)
  188. }else{
  189. cityList.value = []
  190. }
  191. pageSearch()
  192. })
  193. //4.搜索 end ---------------------------------------->
  194. //5.广告 start ---------------------------------------->
  195. //获得所有广告
  196. let adImg1 = ref({})
  197. onMounted(async () => {
  198. const { $webUrl, $CwebUrl } = useNuxtApp();
  199. //从客户端启动广告
  200. //广告1
  201. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_shopsearch_0001`
  202. const responseAd1 = await fetch(url, {
  203. headers: {
  204. 'Content-Type': 'application/json',
  205. 'Userurl': $CwebUrl,
  206. 'Origin': $CwebUrl
  207. }
  208. });
  209. const resultAd1 = await responseAd1.json();
  210. adImg1.value = resultAd1.data[0];
  211. })
  212. //5.广告 end ---------------------------------------->
  213. //6.设置seo信息 start---------------------------------------->
  214. //获得当前的完整路径
  215. const fullPath = route.path;
  216. //拆分,取出来中间这一段,然后提取数字部分
  217. const segments = fullPath.split('/');
  218. const targetSegment = segments[1];
  219. const articleId = ref(0);
  220. //通过导航路径反向查询导航id
  221. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  222. method: 'GET',
  223. query: {
  224. 'pinyin': targetSegment,
  225. },
  226. });
  227. if (getRouteId.code == 200) {
  228. articleId.value = getRouteId.data.category_id
  229. } else {
  230. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  231. console.log("错误位置:通过url路径查询导航池id")
  232. console.log("后端错误反馈:", getRouteId.message)
  233. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  234. }
  235. //6.1 设置seo信息
  236. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  237. method: 'GET',
  238. query: {
  239. 'catid': articleId.value
  240. },
  241. });
  242. if (setData.code == 200) {
  243. let seoTitle = setData.data.seo_title;
  244. let seoDescription = setData.data.seo_description;
  245. let seoKeywords = setData.data.seo_keywords;
  246. let seoSuffix = setData.data.suffix;
  247. let seoName = setData.data.website_name;
  248. useSeoMeta({
  249. title: seoTitle + "_搜索_求购_" + seoName + "_" + seoSuffix,
  250. meta: [
  251. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  252. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  253. { name: 'viewport', content:"width=device-width,initial-scale=1,user-scalable=no"}
  254. ]
  255. });
  256. } else {
  257. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  258. // console.log("错误位置:设置列表页面SEO数据")
  259. // console.log("后端错误反馈:", setData.message)
  260. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  261. }
  262. //6.设置seo信息 end---------------------------------------->
  263. </script>
  264. <style lang="less" scoped>
  265. @import '@/assets/css/shop/list.less';
  266. </style>
  267. <style lang="less" scoped>
  268. @media screen and (min-width:801px){/*pc*/
  269. .page_pc_none{display:none!important;}
  270. .pc_none{display:none;}
  271. }
  272. @media screen and (max-width:800px){/*ipad_phone*/
  273. .index_main{width:100%;margin:0px auto;}
  274. .breadcrumb_box{
  275. height:22px;width:100%;margin:10px auto;
  276. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  277. width:92%;
  278. font-size:14px;
  279. color:#666;
  280. *{
  281. font-size:14px;
  282. display:inline ;
  283. color:#666;
  284. line-height:22px;height:22px;
  285. margin-right:5px;
  286. }
  287. }
  288. .categ_crumb_right{width:92%;margin:0px auto 11px;float:none;display:none;}
  289. .categ_crumb_panel{width:92%;left:4%;}
  290. .categ_grey_box{width:92%;margin:10px auto;display:none;}
  291. .categ_1_index{margin:0px auto;width:92%;}
  292. .categ_head_box{padding-bottom:10px;}
  293. .categ_head_box .categ_head_a{font-size:16px;}
  294. .categ_head_box .categ_head_a_more{font-size:12px;}
  295. .categ_table_li{
  296. height:auto;padding:10px 0px;overflow:hidden;
  297. a{display:block;overflow:hidden;}
  298. .categ_table_td_1{height:33vw;width:33vw;margin-right:0px; }
  299. .categ_table_td_1_img{width:100%;height:100%;}
  300. .search_table_td_2{width:55vw; margin-right:0;float:right;height:auto;}
  301. .search_table_td_2_in{width:100%;display:block;vertical-align:top;height:auto;}
  302. .search_table_td_2_head{width:100%;margin-top:8px;}
  303. .search_table_td_2_dot2{width:100%;margin-bottom:8px;-webkit-line-clamp:1;height:18px;}
  304. .search_table_td_2_dot3{width:100%;-webkit-line-clamp:1;}
  305. .categ_table_td_3{
  306. float:left;text-align:right;width:auto;line-height:22px;height:22px;margin:0 4vw;font-size:14px;
  307. border:solid 1px #E9E9E9;
  308. padding:0px 4px;
  309. }
  310. .categ_table_td_4{
  311. padding:0px 4px;
  312. border:solid 1px #E9E9E9;
  313. height:22px;line-height:22px;float:left;text-align:right;width:auto;font-size:14px;
  314. }
  315. }
  316. .categ_crumb_box{padding:0;margin:0;}
  317. .phone_categ_crumb_out{
  318. width:92%;margin:0px auto 8px;position:relative;
  319. }
  320. .categ_crumb_city{
  321. float:left;
  322. padding:0px 10px;border-radius:8px;
  323. background:rgba(160,28,14,.1);
  324. .categ_crumb_right_text{float: left;
  325. height: 21px;
  326. line-height: 21px;
  327. color: #333;margin-right:4px;
  328. font-size: 14px;
  329. }
  330. .categ_crumb_right_btn{
  331. float: left;
  332. height: 11px;width:11px;
  333. margin:4px 0px 0px 5px;
  334. background-image:url(../../../public/image/9.png);
  335. }
  336. .categ_crumb_right_btn_pull{
  337. background-image:url(../../../public/image/10.png);
  338. }
  339. .phone_categ_crumb_city_panel{
  340. position:absolute;top:122%;right:0px;
  341. border:solid 1px #A01C0E;background:#fff;
  342. width:100%;overflow:auto;height:440px;z-index: 111;
  343. }
  344. .phone_categ_crumb_city_panel_span{
  345. display:block;padding:6px 4px;
  346. color:#333;font-size:14px;line-height:18px;
  347. }
  348. .phone_categ_crumb_city_panel_span_only{
  349. color:#A01C0E;font-weight:bold;
  350. }
  351. }
  352. .phone_categ_crumb_zone{
  353. margin-left:8px;float:right;
  354. padding:0px 10px;border-radius:8px;
  355. background:rgba(160,28,14,.1);
  356. .phone_categ_crumb_zone_text{
  357. float:left;line-height:21px;height:21px;color:#333;font-size:14px;
  358. }
  359. .phone_categ_crumb_zone_btn{
  360. float:right;
  361. height:11px;width:11px;
  362. margin:4px 0px 0px 5px;
  363. background-image:url(../../../public/image/9.png);
  364. }
  365. .phone_categ_crumb_zone_btn_pull{
  366. background-image:url(../../../public/image/10.png);
  367. }
  368. .phone_categ_crumb_zone_panel{
  369. position:absolute;top:122%;right:0px;
  370. border:solid 1px #A01C0E;
  371. background:#fff;z-index: 111;
  372. width:100%;height:440px;overflow:auto;
  373. }
  374. .phone_categ_crumb_zone_panel_span{
  375. display:block;padding:6px 4px;
  376. color:#333;font-size:14px;line-height:18px;
  377. }
  378. .phone_categ_crumb_zone_panel_span_only{
  379. font-weight:bold;color:#A01C0E;
  380. }
  381. }
  382. .pagination{margin:25px auto 0px;}
  383. .page_phone_none{display:none!important;}
  384. .pagination /deep/.el-pagination.is-background .el-pager li{margin:0px 4px;}
  385. .phone_categ_crumb_out::after{content: '';display: block;height: 0;visibility: hidden;clear: both;}
  386. .pc_categ_crumb_panel_none{ display:none!important; }
  387. .categ_table_head_box{display:none;}
  388. .phone_none{display:none;}
  389. }
  390. </style>